package copy;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;

public class ResourceCopy {

	public static void copy(String resourceName, File outputFile)
		throws Throwable {

		BufferedOutputStream output = new BufferedOutputStream(
			new FileOutputStream(outputFile));
		BufferedInputStream input = 
			new BufferedInputStream(ResourceCopy.class
			.getResourceAsStream(resourceName));

		byte[] bytes = new byte[256];
		int num = -1;

		while ((num = input.read(bytes, 0, 256)) != -1) {
			output.write(bytes, 0, num);
		}

		input.close();
		output.close();
	}

}
